import request from '@/utils/request'

export function getList(params) {
  return request({
    url: `/online/management/operator/advance`,
    method: 'get',
    params
  })
}

export function saveTask(data) {
  return request({
    url: `/online/management/operator/advance`,
    method: 'post',
    data
  })
}

export function importByGroup(batchId) {
  return request({
    url: `/online/management/operator/advance/device/batch/${batchId}`,
    method: 'post'
  })
}

export function importBySn(devSn, type) {
  return request({
    url: `/online/management/operator/advance/device/${devSn}?type=${type}`,
    method: 'post'
  })
}

export function importByDeployment(deploymentId) {
  return request({
    url: `/online/management/operator/advance//device/group/${deploymentId}`,
    method: 'post'
  })
}

export function importByModel(modelCode) {
  return request({
    url: `/online/management/operator/advance/device/model/${modelCode}`,
    method: 'post'
  })
}

export function importByLocation(data) {
  return request({
    url: `/online/management/operator/advance/device/location`,
    method: 'post',
    data
  })
}

export function importByOrg(data) {
  return request({
    url: `/online/management/operator/advance/device/orgs`,
    method: 'post',
    data
  })
}

export function deleteDevices(params) {
  return request({
    url: `/online/management/operator/advance/device`,
    method: 'delete',
    params
  })
}

export function stopTask(taskUuid) {
  return request({
    url: `/online/management/operator/advance/${taskUuid}/stop`,
    method: 'post'
  })
}

export function stopTaskTarget(taskUuid, devSn) {
  return request({
    url: `/online/management/operator/advance/${taskUuid}/stop/device/${devSn}`,
    method: 'post'
  })
}

export function importByFile(data) {
  return request({
    url: `/online/management/operator/advance/device/file`,
    method: 'post',
    data,
    timeout: 10 * 60 * 1000
  })
}

export function getTargetList(params) {
  return request({
    url: `/online/management/operator/advance/device/import/detail`,
    method: 'get',
    params
  })
}

export function getFileTargetList(params) {
  return request({
    url: `/online/management/operator/advance/device/file/import/detail`,
    method: 'get',
    params
  })
}
export function getModelAndDeviceFlagList(params) {
  return request({
    url: `/online/management/operator/advance/model-devflag`,
    method: 'get',
    params
  })
}

export function getModelList(params) {
  return request({
    url: `/online/management/operator/advance/model`,
    method: 'get',
    params
  })
}

export function getTaskDetail(taskUuid) {
  return request({
    url: `/online/management/operator/advance/${taskUuid}/detail`,
    method: 'get'
  })
}

export function getTaskDevices(taskUuid, params) {
  return request({
    url: `/online/management/operator/advance/${taskUuid}/device`,
    method: 'get',
    params
  })
}

export function getTaskProgress(taskUuid) {
  return request({
    url: `/online/management/task-center/task/${taskUuid}`
  })
}
